package router

import (
	"github.com/gin-gonic/gin"
	"short-link/internal/controllers"
	"short-link/internal/services"
	"short-link/pkg"
)

func LoadUrlRouter(r *gin.Engine) {
	genertor := services.NewShortCodeGenerator(pkg.Config.Server.CodeLen)
	cache := services.NewRedisCache(pkg.Cache)
	urlService := services.NewURLServiceImpl(pkg.DB, genertor, pkg.Config.Server.DefaultDuration, cache)
	controller := controllers.NewUrlController(urlService, pkg.Config.Server.BaseURL)

	r.POST("url/add", controller.Add)
	r.GET("/:code", controller.RedirectURL)

	r.GET("/health", controller.SayHello)
}
